//
//  ImageAnnotaionView.m
//  DemoMeshtiles
//
//  Created by MAC on 7/20/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ImageAnnotaionView.h"

@implementation ImageAnnotaionView
@synthesize egoView=_egoView;
-(id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier
{
    [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
    
    if (self!=nil) {
        CGRect frame = self.frame;
        frame.size = CGSizeMake(56.0, 62.0);
        self.frame = frame;
        self.backgroundColor = [UIColor clearColor];
        self.centerOffset = CGPointMake(-0, -0);
        _egoView =[[EGOImageView alloc] initWithPlaceholderImage:[UIImage imageNamed:@"244.png"]];
    }
    return self;
}
- (void)setAnnotation:(id <MKAnnotation>)annotation
{
    [super setAnnotation:annotation];
    
    // this annotation view has custom drawing code.  So when we reuse an annotation view
    // (through MapView's delegate "dequeueReusableAnnoationViewWithIdentifier" which returns non-nil)
    // we need to have it redraw the new annotation data.
    //
    // for any other custom annotation view which has just contains a simple image, this won't be needed
    //
    [self setNeedsDisplay];
}
-(void)setImageURL:(NSString*)imageURL {
    [_egoView setImageURL:[NSURL URLWithString:imageURL]];
}

- (void)drawRect:(CGRect)rect
{
    
    [[UIImage imageNamed:@"map_image_bg.png"] drawInRect:CGRectMake(0, 0, 56, 62)];        
 //  [[UIImage imageNamed:@"thumb1.jpeg"] drawInRect:CGRectMake(8, 8, 56-10*2, 56-10*2)];
    [_egoView.image drawInRect:CGRectMake(8, 8, 56-10*2, 56-10*2)];
    NSLog(@"execute draw Rect in ImageAnnotaion View");
}


@end
